
<table width="100%"  border="0" cellpadding="3" cellspacing="1">
  <form action="?" method="get" name="getInvoices" runat="server">
  <input type="hidden" name="jB" value="">
    <tr bgcolor="#99CCCC">
      <td bgcolor="#ACB1CC" colspan="8">Pesquisar</td>
    </tr>
 
  <tr bgcolor="#F2F2F2">
    <td width="0">N. Factura 
    <input name="IReference" type="text" id="IReference" size="10"></td>
    <td width="0">N. Interno    
      <input name="Invoice" type="text" id="Invoice" size="10"></td>
    <td width="0">Fornecedor
      <select name="Provider" id="Provider">
	  <option value=""> </option>
		<?php
		$CList = "SELECT ccenter_providers.ref, ccenter_providers.name
	  			FROM ccenter_providerscodes
				INNER JOIN ccenter_providers ON ccenter_providers.ref = ccenter_providerscodes.RefProvider
				ORDER BY name ASC";
		$List = $GLOBALS['CONN']->db_array($CList);
		for($r = 1; $r <= $List[0]; $r++) {
		print '<option value="'.$List[$r]['ref'].'" ';
		if (isset($_POST['Provider']) && $_POST['Provider'] == $List[$r]['ref']) { print 'selected';}
		print '>'.$List[$r]['name'].'</option>';
		} ?>
   </select></td>
    <td width="0">Valor
    <input name="Amount" type="text" id="Amount" size="10"></td>
    <td width="0"><input type="submit" name="Search" value="Pesquisar"></td>
  </tr>
  </form>
</table>
<br>
<table width="100%"  border="0" cellpadding="3" cellspacing="1">
  <form action="?" method="get" name="getInvoices" runat="server">
    <tr bgcolor="#99CCCC">
      <td bgcolor="#ACB1CC" colspan="5">Calendário de Responsabilidades</td>
    </tr>
  </form>
  <tr bgcolor="#F2F2F2">
    <td width="50%">Mês 
	<?php 
	if (!isset($_GET['ScdTime'])) { 
		$ScdTime = date("Y-m-d H:i:s");
	} else {
		$ScdTime = $_GET['ScdTime'];
	}
	$ConsultTime = split("-",$ScdTime);
	scdconsult($ScdTime,'getInvoices');?>
      </td>
    <td width="50%">PrÓximas Responsabilidades </td>
  </tr>
  <tr bgcolor="#F2F2F2">
    <td valign="top">
	<?php
	$ScdCalend = "SELECT DAY(TimePay) AS Event
					FROM ccenter_invoices
					WHERE TYPE = 2
					AND TimePay";
	scdttable($ScdCalend,$ConsultTime); ?></td>
    <td valign="top">
	<?php 
	$ScdList = "SELECT 
				YEAR(ccenter_invoices.Time) AS FactRef,
				ccenter_invoices.RefProvider,
				ccenter_invoices.Ref,
				main_offices.name AS Office,
				main_users.name AS User,
				ccenter_invoices.Description,
				ccenter_invoices.Amount,
				DATE(ccenter_invoices.Time),
				DATE(ccenter_invoices.TimeInvoice) AS TimeInvoice,
				ccenter_invoices.Status,
				ccenter_providers.name AS Provider,
				ccenter_invoices.CODE
			FROM ccenter_invoices
				LEFT OUTER JOIN main_offices ON main_offices.ref = ccenter_invoices.RefOffice
				LEFT OUTER JOIN main_users ON main_users.ref = ccenter_invoices.RefUser
				LEFT OUTER JOIN ccenter_providers ON ccenter_providers.Ref = ccenter_invoices.RefProvider
			WHERE ccenter_invoices.Type = 2
		  		AND YEAR(TimePay) = YEAR('{$ScdTime}')
				AND MONTH(TimePay) = MONTH('{$ScdTime}')
				ORDER BY TimePay ASC";
	scdlist($ScdList); ?>
	</td>
  </tr>
</table>